package horncomb.bpm.process.event;

/**
 * @author Daniel
 */
public class EventDispatcher {
	public void publishEvent(Event event, EventTarget target) {
		EventContext context = new EventContext();
		context.setTarget(target);
		event.trigger(context);
		EventTarget parent = target.getParent();
		// 传播事件
		while (parent != null && event.isPropagation()) {
			context.setTarget(parent);
			event.trigger(context);
			parent = parent.getParent();
		}
	}
}
